package a8;

public class FibonacciGenerator {
	/**
	 * Create new generator
	 */
	public FibonacciGenerator() {
		f1 = 1;
		f2 = 1;
		f3 = 0;
		i = 0;
	}
	/**
	 * 
	 * @return Next number in the fibonacci sequence
	 */
	public int nextNumber() {
		if(i < 2){
			i++;
			return f1;
		}
		f3 = f1 + f2;
		f1 = f2;
		f2 = f3;

		return f3;
	}
	
	private int f1;
	private int f2;
	private int f3;
	private int i;
}
